package com.lzp.service.impl;

import com.lzp.service.StuService;
import com.lzp.service.TransactionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 测试事务传播
 *
 * @author lzp
 * @date 2020/6/29
 */
@Service
public class TransactionalServiceImpl implements TransactionalService {
    @Autowired
    private StuService stuService;

    // @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void testPropagation() {
        // stuService.saveParent();
        stuService.saveChildren();
        // int a = 1 / 0;
    }

    @Override
    public void testRockbackFor() {
        stuService.saveStuWithRollbackFor();
    }

    @Override
    public void testWithoutRockbackFor() {
        stuService.saveStuWithoutRollbackFor();
    }
}
